#include <stdio.h>

int main(void)
{
	static int a[3] = {0x11, 0x22, 0x33};
	int i, s = 0, b[3];

	for (i = 0; i < 3; i++) {
		s = s + a[i];
		b[i] = s;
	}

	for (i = 0; i < 3; i++) {
		printf("%d\n", b[i]);
	}

	return 0;
}

#if 0

int main(void)
{
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 83 ec 20          	sub    $0x20,%rsp
    1175:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    117c:	00 00 
    117e:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    1182:	31 c0                	xor    %eax,%eax
	static int a[3] = {0x11, 0x22, 0x33};
	int i, s = 0, b[3];
    1184:	c7 45 e8 00 00 00 00 	movl   $0x0,-0x18(%rbp)			# s = rbp-0x18 = 0

	for (i = 0; i < 3; i++) {
    118b:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%rbp)			# i = rbp-0x1c = 0
    1192:	eb 2a                	jmp    11be <main+0x55>
		s = s + a[i];
    1194:	8b 45 e4             	mov    -0x1c(%rbp),%eax			# eax = rbp-0x1c = i
    1197:	48 98                	cltq							# œ«Ð¡µÄÊýŸÝžŽÖÆµœŽóµÄÄ¿µÄµØ£¬µÈŒÛ movslq %eax,%rax
																	# (Ë«×Ö->ËÄ×Ö£¬·ûºÅÌî³ä)
																	# rax = i
    1199:	48 8d 14 85 00 00 00 	lea    0x0(,%rax,4),%rdx		# rdx = rax*4 + 0x0
																	# rdx=rax*4£¬ÒòÎª eax ÊÇ rax µÄµÍ32Î»£¬
																	# eaxµÄÖµÊÇ±äÁ¿ i£¬ËùÒÔÕâÀï rdx=i*4
    11a0:	00 
    11a1:	48 8d 05 68 2e 00 00 	lea    0x2e68(%rip),%rax        # 4010 <a.2316>		rax = rip+0x2e68 = a[]
    11a8:	8b 04 02             	mov    (%rdx,%rax,1),%eax		# eax = (rdx+rax*1)	= i+a[]
    11ab:	01 45 e8             	add    %eax,-0x18(%rbp)			# s = rbp-0x18 + eax,  s = s + a[i]
		b[i] = s;
    11ae:	8b 45 e4             	mov    -0x1c(%rbp),%eax			# eax = rbp-0x1c = i
    11b1:	48 98                	cltq							# rax = i
    11b3:	8b 55 e8             	mov    -0x18(%rbp),%edx			# edx = rbp-0x18 = s
    11b6:	89 54 85 ec          	mov    %edx,-0x14(%rbp,%rax,4)	# (rbp+rax*4)-0x14 = edx, b[i] = s
	for (i = 0; i < 3; i++) {
    11ba:	83 45 e4 01          	addl   $0x1,-0x1c(%rbp)			# i = rbp-0x1c + 1
    11be:	83 7d e4 02          	cmpl   $0x2,-0x1c(%rbp)			# 0x2 - i
    11c2:	7e d0                	jle    1194 <main+0x2b>
	}

	for (i = 0; i < 3; i++) {
    11c4:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%rbp)			# i = 0
    11cb:	eb 20                	jmp    11ed <main+0x84>
		printf("%d\n", b[i]);
    11cd:	8b 45 e4             	mov    -0x1c(%rbp),%eax			# eax = rbp-0x1c = i
    11d0:	48 98                	cltq							# rax <--- eax
    11d2:	8b 44 85 ec          	mov    -0x14(%rbp,%rax,4),%eax	# eax = (rbp+rax*4)-0x14 =  b[i]
    11d6:	89 c6                	mov    %eax,%esi				# esi = eax
    11d8:	48 8d 3d 25 0e 00 00 	lea    0xe25(%rip),%rdi			# 2004 <_IO_stdin_used+0x4>
    11df:	b8 00 00 00 00       	mov    $0x0,%eax				# eax = 0
    11e4:	e8 87 fe ff ff       	callq  1070 <printf@plt>
	for (i = 0; i < 3; i++) {
    11e9:	83 45 e4 01          	addl   $0x1,-0x1c(%rbp)			# i = i + 1
    11ed:	83 7d e4 02          	cmpl   $0x2,-0x1c(%rbp)			# 0x2 - i
    11f1:	7e da                	jle    11cd <main+0x64>
	}

	return 0;
    11f3:	b8 00 00 00 00       	mov    $0x0,%eax
}
    11f8:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    11fc:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    1203:	00 00 
    1205:	74 05                	je     120c <main+0xa3>
    1207:	e8 54 fe ff ff       	callq  1060 <__stack_chk_fail@plt>
    120c:	c9                   	leaveq 
    120d:	c3                   	retq   
    120e:	66 90                	xchg   %ax,%ax

#if 0

/*
 * intel
 */
0000000000001169 <main>:
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 83 ec 20          	sub    $0x20,%rsp
    1175:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    117c:	00 00 
    117e:	48 89 45 f8          	mov    %rax,-0x8(%rbp)	// (rbp-0x8)=rax
    1182:	31 c0                	xor    %eax,%eax	// eax=0
    1184:	c7 45 e8 00 00 00 00 	movl   $0x0,-0x18(%rbp)	// (rbp-0x18)=0x0
    118b:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%rbp)	// (rbp-0x1c)=0
    1192:	eb 2a                	jmp    11be <main+0x55>	// jump
    1194:	8b 45 e4             	mov    -0x1c(%rbp),%eax	// eax=(rbp-0x1c)
    1197:	48 98                	cltq   
    1199:	48 8d 14 85 00 00 00 	lea    0x0(,%rax,4),%rdx
    11a0:	00 
    11a1:	48 8d 05 68 2e 00 00 	lea    0x2e68(%rip),%rax        # 4010 <a.2316>	rax=rip+0x2e68
    11a8:	8b 04 02             	mov    (%rdx,%rax,1),%eax	// eax=(rdx+rax*1)
    11ab:	01 45 e8             	add    %eax,-0x18(%rbp)		// (rbp-0x18)=eax
    11ae:	8b 45 e4             	mov    -0x1c(%rbp),%eax		// eax=(rbp-0x1c)
    11b1:	48 98                	cltq   
    11b3:	8b 55 e8             	mov    -0x18(%rbp),%edx		// edx=(rbp-0x18)
    11b6:	89 54 85 ec          	mov    %edx,-0x14(%rbp,%rax,4)	// (rbp+rax*4)-0x14=edx
    11ba:	83 45 e4 01          	addl   $0x1,-0x1c(%rbp)		// (rbp-0x1c)=0x1
    11be:	83 7d e4 02          	cmpl   $0x2,-0x1c(%rbp)		// (rbp-0x1c)-0x2
    11c2:	7e d0                	jle    1194 <main+0x2b>		// <= jump
    11c4:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%rbp)		// (rbp-0x1c)=0
    11cb:	eb 20                	jmp    11ed <main+0x84>		// jump
    11cd:	8b 45 e4             	mov    -0x1c(%rbp),%eax		// eax=(rbp-0x1c)
    11d0:	48 98                	cltq   
    11d2:	8b 44 85 ec          	mov    -0x14(%rbp,%rax,4),%eax	// eax=(rbp+rax*4-0x14)
    11d6:	89 c6                	mov    %eax,%esi		// esi=eax
    11d8:	48 8d 3d 25 0e 00 00 	lea    0xe25(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>
    11df:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    11e4:	e8 87 fe ff ff       	callq  1070 <printf@plt>
    11e9:	83 45 e4 01          	addl   $0x1,-0x1c(%rbp)		// (rbp-0x1c)=0x1
    11ed:	83 7d e4 02          	cmpl   $0x2,-0x1c(%rbp)		// (rbp-0x1c)-0x2
    11f1:	7e da                	jle    11cd <main+0x64>		// <= jump
    11f3:	b8 00 00 00 00       	mov    $0x0,%eax
    11f8:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    11fc:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    1203:	00 00 
    1205:	74 05                	je     120c <main+0xa3>
    1207:	e8 54 fe ff ff       	callq  1060 <__stack_chk_fail@plt>
    120c:	c9                   	leaveq 
    120d:	c3                   	retq   
    120e:	66 90                	xchg   %ax,%ax

/*
 * arm
 */
000000000040055c <main>:
  40055c:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
  400560:	910003fd 	mov	x29, sp
  400564:	b9002bbf 	str	wzr, [x29, #40]		// [x29+40]=0
  400568:	b9002fbf 	str	wzr, [x29, #44]		// [x29+44]=0
  40056c:	14000010 	b	4005ac <main+0x50>
  400570:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400574:	9100c000 	add	x0, x0, #0x30		// x0=411030
  400578:	b9802fa1 	ldrsw	x1, [x29, #44]		// x1=[x29+44]
  40057c:	b8617800 	ldr	w0, [x0, x1, lsl #2]	// w0=[x0+x1<<2]
  400580:	b9402ba1 	ldr	w1, [x29, #40]		// w1=[x29+40]
  400584:	0b000020 	add	w0, w1, w0		// w0=w1+w0
  400588:	b9002ba0 	str	w0, [x29, #40]		// [x29+40]=w0
  40058c:	b9802fa0 	ldrsw	x0, [x29, #44]		// x0=[x29+44]
  400590:	d37ef400 	lsl	x0, x0, #2		// x0=x0<<2
  400594:	910063a1 	add	x1, x29, #0x18		// x1=x29+0x18
  400598:	b9402ba2 	ldr	w2, [x29, #40]		// w2=[x29+40]
  40059c:	b8206822 	str	w2, [x1, x0]		// [x1+x0]=w2
  4005a0:	b9402fa0 	ldr	w0, [x29, #44]		// w0=[x29+44]
  4005a4:	11000400 	add	w0, w0, #0x1		// w0=w0+0x1
  4005a8:	b9002fa0 	str	w0, [x29, #44]		// [x29+44]=w0
  4005ac:	b9402fa0 	ldr	w0, [x29, #44]		// w0=[x29+44]
  4005b0:	7100081f 	cmp	w0, #0x2		// w0-2
  4005b4:	54fffded 	b.le	400570 <main+0x14>	// 带符号 <=
  4005b8:	b9002fbf 	str	wzr, [x29, #44]		// [x29+44]=0
  4005bc:	1400000b 	b	4005e8 <main+0x8c>
  4005c0:	b9802fa0 	ldrsw	x0, [x29, #44]		// x0=[x29+44]
  4005c4:	d37ef400 	lsl	x0, x0, #2		// x0=x0<<2
  4005c8:	910063a1 	add	x1, x29, #0x18		// x1=x29+x018
  4005cc:	b8606821 	ldr	w1, [x1, x0]		// w1=[x1+x0]
  4005d0:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  4005d4:	911ac000 	add	x0, x0, #0x6b0		// x0=4006b0
  4005d8:	97ffff9e 	bl	400450 <printf@plt>
  4005dc:	b9402fa0 	ldr	w0, [x29, #44]		// w0=[x29+44]
  4005e0:	11000400 	add	w0, w0, #0x1		// w0=w0+1
  4005e4:	b9002fa0 	str	w0, [x29, #44]		// [x29+44]=w0
  4005e8:	b9402fa0 	ldr	w0, [x29, #44]		// w0=[x29+44]
  4005ec:	7100081f 	cmp	w0, #0x2		// w0-0x2
  4005f0:	54fffe8d 	b.le	4005c0 <main+0x64>
  4005f4:	52800000 	mov	w0, #0x0                   	// #0
  4005f8:	a8c37bfd 	ldp	x29, x30, [sp], #48
  4005fc:	d65f03c0 	ret

#endif
#endif
